<!DOCTYPE html>
<html>

<head>
    <title>{$Think.config.app_name}</title>
    {include file="public/head"/}
</head>

<body class="layui-layout-body">
    <div id="LAY_app" class="layadmin-tabspage-none">
        <div class="layui-layout layui-layout-admin">
            {include file="public/menu"/}
            <div class="layui-body root_box" v-cloak>
                <fieldset class="layui-elem-field">
                    <legend>基本设置</legend>
                    <form class="layui-form" action="" lay-filter="example">
                        <div class="layui-form-item" v-for="(item, index) in list" :key="index">
                            <label class="layui-form-label">{{item.conf_desc}}</label>
                            <div class="layui-input-block">
                                <input v-if="item.conf_readonly==1" disabled="disabled" type="text"
                                    placeholder="请输入配置名称" class="layui-input layui-input-readonly"
                                    v-model="item.conf_key">
                                <input v-else type="text" placeholder="请输入配置名称" class="layui-input"
                                    v-model="item.conf_value">
                                <div v-if="item.conf_readonly==1">只读配置项不允许修改</div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button type="button" class="layui-btn" @click="submit">立即提交</button>
                            </div>
                        </div>
                    </form>
                </fieldset>
            </div>
        </div>
    </div>
</body>
{include file="public/foot"/}
<script>
    var app = new Vue({
        el: ".root_box",
        data: {
            list: []
        },
        created: function () {
            $.post("/api/conf/getBaseConfig", Object.assign({
            }, PostCommon), function (data, status) {
                _hideLoading();
                if (data.code != 200) {
                    _alert(data.msg);
                } else {
                    app.list = data.data;
                }
            });
        },
        methods: {
            submit: function () {
                var postData = {};
                for (var i = 0; i < this.list.length; i++) {
                    postData[this.list[i].conf_key] = this.list[i].conf_value;
                }
                _loading();
                $.post("/api/conf/updateBaseConfig", Object.assign(postData, PostCommon), function (data, status) {
                    _hideLoading();
                    _alert(data.msg,'修改成功', function () {
                        if (data.code == 200) {
                            location.replace(location.href);
                        }
                    });
                });
            },
        }
    });
</script>

</html>